package com.ncloud.param.mapper;

import java.util.List;

import org.apache.ibatis.annotations.*;

import com.ncloud.param.entity.CountyInfo;

@Mapper
public interface CountyInfoMapper {

	@Select("select * from bs_p_county_info where level=#{level} and deal_tag='1'")
	@Results({ @Result(column = "county_id", property = "countyId"),
			@Result(column = "county_name", property = "countyName"),
			@Result(column = "longitude", property = "longitude"), @Result(column = "latitude", property = "latitude"),
			@Result(column = "parent_id", property = "parentId"), @Result(column = "level", property = "level"),
			@Result(column = "deal_tag", property = "dealTag"), @Result(column = "deal_time", property = "dealTime"),
			@Result(column = "rsrv_str1", property = "rsrvStr1"), @Result(column = "rsrv_str2", property = "rsrvStr2"),
			@Result(column = "rsrv_str3", property = "rsrvStr3") })
	List<CountyInfo> getCountyInfoByLevel(String level);

	@Select("select * from bs_p_county_info where parent_id=#{parentId} and deal_tag='1'")
	@Results({ @Result(column = "county_id", property = "countyId"),
		@Result(column = "county_name", property = "countyName"),
		@Result(column = "longitude", property = "longitude"), @Result(column = "latitude", property = "latitude"),
		@Result(column = "parent_id", property = "parentId"), @Result(column = "level", property = "level"),
		@Result(column = "deal_tag", property = "dealTag"), @Result(column = "deal_time", property = "dealTime"),
		@Result(column = "rsrv_str1", property = "rsrvStr1"), @Result(column = "rsrv_str2", property = "rsrvStr2"),
		@Result(column = "rsrv_str3", property = "rsrvStr3") })
	List<CountyInfo> getCountyInfoByParent(String parentId);

	@Select("select a.*  from bs_p_county_info a ,bs_p_county_attr_release b where a.LEVEL='1' " +
			" and a.county_id = b.province_id and a.PARENT_ID='-1' and b.state='1' and b.sla_level=#{slaLevel} GROUP by b.province_id  ")
	@Results({ @Result(column = "county_id", property = "countyId"),
			@Result(column = "county_name", property = "countyName"),
			@Result(column = "longitude", property = "longitude"), @Result(column = "latitude", property = "latitude"),
			@Result(column = "parent_id", property = "parentId"), @Result(column = "level", property = "level"),
			@Result(column = "deal_tag", property = "dealTag"), @Result(column = "deal_time", property = "dealTime"),
			@Result(column = "rsrv_str1", property = "rsrvStr1"), @Result(column = "rsrv_str2", property = "rsrvStr2"),
			@Result(column = "rsrv_str3", property = "rsrvStr3") })
	List<CountyInfo> getProvinceInfoBySalLevel(String slaLevel);

	@Select("select a.* from bs_p_county_info a ,bs_p_county_attr_release b where a.LEVEL='2' and a.county_id = b.city_id " +
			"and b.sla_level=#{slaLevel}  and b.province_id=#{provinceId} and b.state='1' ")
	@Results({ @Result(column = "county_id", property = "countyId"),
			@Result(column = "county_name", property = "countyName"),
			@Result(column = "longitude", property = "longitude"), @Result(column = "latitude", property = "latitude"),
			@Result(column = "parent_id", property = "parentId"), @Result(column = "level", property = "level"),
			@Result(column = "deal_tag", property = "dealTag"), @Result(column = "deal_time", property = "dealTime"),
			@Result(column = "rsrv_str1", property = "rsrvStr1"), @Result(column = "rsrv_str2", property = "rsrvStr2"),
			@Result(column = "rsrv_str3", property = "rsrvStr3") })
	List<CountyInfo> getCityInfoBySalLevel(@Param("slaLevel") String discntId,@Param("provinceId") String provinceId);
	
	@Select("select * from bs_p_county_info where county_id=#{countyId}")
	@Results({ @Result(column = "county_id", property = "countyId"),
			@Result(column = "county_name", property = "countyName"),
			@Result(column = "longitude", property = "longitude"), @Result(column = "latitude", property = "latitude"),
			@Result(column = "parent_id", property = "parentId"), @Result(column = "level", property = "level"),
			@Result(column = "deal_tag", property = "dealTag"), @Result(column = "deal_time", property = "dealTime"),
			@Result(column = "rsrv_str1", property = "rsrvStr1"), @Result(column = "rsrv_str2", property = "rsrvStr2"),
			@Result(column = "rsrv_str3", property = "rsrvStr3") })
	CountyInfo getCountyByID(@Param("countyId") String countyId);
}
